<!---

Copyright 2008:

Author: Marco van den Oever
Company: WSO
Website: http://www.webserviceonline.biz
Email: marco@webserviceonline.biz

License: 

This software is licensed under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
For a copy of the GNU General Public License check the license folder or see <http://www.gnu.org/licenses/>.

Description:

wsoFarcryPolling, a Farcry plugin to show pollings on a Farcry based project

Build with great support from the Farcry-Dev group! (Google on Farcry-Dev)

Created: 18/10/08

Tested on CF8

--->
<cfsetting enablecfoutputonly="true" />
<cfimport taglib="/farcry/core/tags/formtools" prefix="ft" />
<cfimport taglib="/farcry/core/tags/extjs" prefix="extjs" />
<cfimport taglib="/farcry/core/tags/webskin" prefix="skin" />

<ft:processForm action="Save">
  <ft:processFormObjects typename="banners" />
</ft:processForm>
<!--- if the form was submitted by the Excel button, save data to Excel --->
<ft:processform action="xls">
  <!--- Import the POI tag library. --->
  <cfimport taglib="/farcry/plugins/wsoFarcryBanners/packages/custom/poi/" prefix="poi" />
  <!--- 
	Create an excel document and store binary data into 
	REQUEST variable. 
--->
  <poi:document 
	name="REQUEST.ExcelData"
	file="#ExpandPath( './banner_statistics.xls' )#"
	style="font-family: verdana ; font-size: 10pt ; color: black ; white-space: nowrap ;">
    <!--- Define style classes. --->
    <poi:classes>
      <poi:class 
			name="header" 
			style="font-family: verdana ; font-size: 10pt ; color: black ; background-color: GREY_25_PERCENT ; border-bottom: solid 3px GREY_40_PERCENT ;" 
			/>
    </poi:classes>
    <!--- Define Sheets. --->
    <poi:sheets>
      <poi:sheet 
			name="banner_statistics"
			freezerow="2"
			orientation="landscape"
			zoom="100%">
        <!--- Define global column styles. --->
        <poi:columns>
          <poi:column style="width: 150px ; text-align: center ;" />
          <poi:column style="width: 150px ; text-align: center ;" />
          <poi:column style="width: 150px ; text-align: center ;" />
          <poi:column style="width: 150px ; text-align: center ;" />
          <poi:column style="width: 150px ; text-align: center ;" />
          <poi:column style="width: 150px ; text-align: center ;" />
          <poi:column style="width: 150px ; text-align: center ;" />
        </poi:columns>
        <!--- Header row. --->
        <poi:row class="header">
          <poi:cell value="Date / Time created" />
          <poi:cell value="Bannerclient" />
          <poi:cell value="Client E-mail" />
          <poi:cell value="Bannername" />
          <poi:cell value="Hits made" />
          <poi:cell value="Hits left" />
          <poi:cell value="Views made" />
          <poi:cell value="Views left" />
        </poi:row>
        <!--- Output the banner data and get the banner client --->
        <cfset obj = createObject('component',application.stcoapi.bannerclients.typePath) />
        <cfset bannerclient = obj.getdata(stobj.abannerclients) />
        <poi:row>
          <poi:cell type="date" value="#stobj.datetimecreated#" />
          <poi:cell value="#bannerclient.contactname#" />
          <poi:cell value="#bannerclient.contactemail#" />
          <poi:cell value="#stobj.bannername#" />
          <poi:cell type="numeric" value="#stobj.hitsmade#" />
          <poi:cell type="numeric" value="#stobj.hitsleft#" />
          <poi:cell type="numeric" value="#stobj.viewsmade#" />
          <poi:cell type="numeric" value="#stobj.viewsleft#" />
        </poi:row>
      </poi:sheet>
    </poi:sheets>
  </poi:document>
  <!--- Tell the browser to expect an Excel file attachment. --->
  <cfheader
	name="content-disposition"
	value="attachment; filename=banner_statistics.xls"
	/>
  <!--- 
	Tell browser the length of the byte array output stream. 
	This will help the browser provide download duration to 
	the user. 
--->
  <cfheader
	name="content-length"
	value="#REQUEST.ExcelData.Size()#"
	/>
  <!--- Stream the binary data to the user. --->
  <cfcontent
	type="application/excel"
	variable="#REQUEST.ExcelData.ToByteArray()#"
	/>
</ft:processform>
<ft:processForm action="Save,Cancel" exit="true" />
<ft:form>
  <ft:object typename="banners" objectid="#stobj.objectid#" lFields="title,description,aTaskDefs,lTypenames" r_stPrefix="prefix" legend="General Details" />
  <!--- if data exists show cfchart --->
  <cfif #stobj.abannerclients# GT 0>
   <!--- show the polling results in cfchart --->
    <cfchart format="png"
chartwidth="300" chartheight="300" showlegend="yes" show3d="yes">
    <cfchartseries type="pie">
	<cfif stobj.hitsmade GT 0>
    <cfchartdata item="hits made" value="#stobj.hitsmade#">
	</cfif>
	<cfif stobj.hitsleft GT 0>
    <cfchartdata item="hits left" value="#stobj.hitsleft#">
	</cfif>
	<cfif stobj.viewsmade GT 0>
    <cfchartdata item="views made" value="#stobj.viewsmade#">
	</cfif>
	<cfif stobj.viewsleft GT 0>
    <cfchartdata item="views left" value="#stobj.viewsleft#">
	</cfif>
    </cfchartseries>
    </cfchart>
  </cfif>
  <extjs:onReady> <cfoutput> Ext.get("#prefix#lTypenames").on('change', this.onClick, this, {
      buffer: 500,
      fn: function() { 
      renderWorkflowDefWebskins('#stobj.objectid#', Ext.get('#prefix#lTypenames').dom.value);
      }
      });
      
      function renderWorkflowDefWebskins(workflowDefID,lTypenames) {
      
      var el = Ext.get("editWebskins");
      
      if (workflowDefID != '') {
      
      el.slideOut('t', {
      easing: 'easeOut',
      duration: .5,
      remove: false,
      useDisplay: true,
      callback: function() {
      el.load({
      url: "#application.url.webtop#/facade/workflowFacade.cfc?method=renderWorkflowDefWebskins",
      scripts: true,
      autoAbort:true,
      callback: function() {
      el.slideIn('t', {
      easing: 'easeIn',
      duration: .5,
      remove: false,
      useDisplay: true
      })
      },
      params: {
      workflowDefID: workflowDefID,
      lTypenames: lTypenames
      }
      });
      }
      })
      
      
      
      }
      
      } </cfoutput> </extjs:onReady>
  <ft:farcryButtonPanel>
    <ft:farcryButton value="Save" />
    <ft:farcryButton value="Cancel" />
     <!--- if data exists show xls export button --->
    <cfif #stobj.abannerclients# GT 0>
      <ft:farcryButton value="xls" />
    </cfif>
  </ft:farcryButtonPanel>
</ft:form>
<cfsetting enablecfoutputonly="false" />
